home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 526-550 / disk_543 / wbplane / addwbplane.asm < prev    next >
Assembly Source File  |  1992-05-06  |  3KB  |  118 lines

  1.  
  2. *    AddWBplane
  3. *
  4. *    Adds a bitplane to the Workbench screen.
  5. *
  6. *
  7. *HISTORY
  8. *         Made with Hisoft V2.12
  9. *  V1.0   27-Jun-91: First attempt. Works of course
  10.  
  11.     OPT O+
  12.     OPT O1+        ; Tells when a branch could be optimised to short
  13.     OPT i+        ; Tells when '#' is probably missing
  14.  
  15.     incdir        "AsmInc:"
  16.     include        "P.i"
  17.     include        "relMacros.i"
  18.     include        "exec/exec_lib.i"
  19.     include        "libraries/dosextens.i"
  20.     include        "graphics/graphics_lib.i"
  21.     include        "intuition/intuition_lib.i"
  22.     include        "intuition/intuition.i"
  23.  
  24. Planes        EQUR        D2
  25. Index        EQUR        D3
  26. WScreen        EQUR        A2
  27. WBitMap        EQUR        A3
  28. DB        EQUR        A4
  29.  
  30.  dcDeclare    A4
  31.  dcAPtr        WBMsg
  32.  dcAPtr        GraphBase
  33.  dcAPtr        IntuiBase
  34.  dcEnd
  35. Start        dcAlloc
  36.         dcReset
  37.         Prepare        Exec_Call
  38.         suba.l        A1,A1
  39.         CallLib        FindTask        ; Find us
  40.         movea.l        D0,A2
  41.         tst.l        pr_CLI(A2)
  42.         bne.S        GetLibs
  43. WBStart        lea        pr_MsgPort(A2),A0
  44.         CallLib        WaitPort        ; wait for a message
  45.         lea        pr_MsgPort(A2),A0
  46.         CallLib        GetMsg            ; then get it
  47.         move.l        D0,WBMsg(DB)        ; save it for later reply
  48. GetLibs        lea        GfxName(PC),A1
  49.         CallLib        OldOpenLibrary
  50.         move.l        D0,GraphBase(DB)
  51.         beq        Error
  52.         lea        IntuiName(PC),A1
  53.         CallLib        OldOpenLibrary
  54.         move.l        D0,IntuiBase(DB)
  55.         beq.S        Error
  56. *»»» Find Workbench screen
  57.         CallLib        Forbid
  58.         move.l        IntuiBase(DB),A0
  59.         move.l        ib_FirstScreen(A0),WScreen
  60. 1$        move.l        WScreen,D0
  61.         beq.S        3$
  62.         move.w        sc_Flags(WScreen),D0
  63.         andi.w        #SCREENTYPE,D0
  64.         cmpi.w        #WBENCHSCREEN,D0    ; Workbench screen ?
  65.         beq.S        2$
  66.         move.l        sc_NextScreen(WScreen),WScreen
  67.         bra.S        1$
  68. *»»» Found Workbench screen
  69. 2$        lea        sc_BitMap(WScreen),WBitMap
  70.         moveq        #0,Planes
  71.         move.b        bm_Depth(WBitMap),Planes
  72.         move.w        Planes,Index
  73.         mulu        #4,Index
  74.         addq.w        #1,Planes
  75.         cmp.w        #4,Planes
  76.         bgt.S        3$
  77.         move.w        sc_Width(WScreen),D0
  78.         move.w        sc_Height(WScreen),D1
  79.         Prepare        Gfx_Call
  80.         CallLib        AllocRaster
  81.         move.l        D0,bm_Planes(WBitMap,Index)
  82.         beq.S        3$
  83.         move.l        D0,A1
  84.         move.w        bm_Rows(WBitMap),D0
  85.         swap        D0
  86.         move.w        bm_BytesPerRow(WBitMap),D0
  87.         moveq        #2,D1
  88.         CallLib        BltClear
  89.         move.b        Planes,bm_Depth(WBitMap)
  90.         Prepare        Intuition_Call
  91.         CallLib        RemakeDisplay
  92. 3$        Prepare        Exec_Call
  93.         CallLib        Permit
  94.  
  95. Error
  96. Exit        Prepare        Exec_Call
  97. FreeIntui    move.l        IntuiBase(DB),D0
  98.         beq.S        FreeGfx
  99.         move.l        D0,A1
  100.         CallLib        CloseLibrary
  101. FreeGfx        move.l        GraphBase(DB),D0
  102.         beq.S        ReplyWB
  103.         move.l        D0,A1
  104.         CallLib        CloseLibrary
  105. ReplyWB        move.l        WBMsg(DB),D2
  106.         beq.S        AllDone
  107.         CallLib        Forbid            ; We were started from WB
  108.         movea.l        D2,A1
  109.         CallLib        ReplyMsg        ; Reply WBMessage
  110. AllDone        dcFree
  111.         moveq        #0,D0
  112.         rts
  113.  
  114. GfxName        dc.b        'graphics.library',0
  115. IntuiName    dc.b        'intuition.library',0
  116.         END
  117.  
  118.